package com.agger.eurekacommonapi.exception;

import com.agger.eurekacommonapi.enums.CommonExceptionEnums;
import lombok.Data;

/**
 * @classname: BusinessException
 * @description: 自定义业务类型异常
 * @author chenhx
 * @date 2020-05-26 11:03:22
 */
@Data
public class BusinessException extends Exception{

    private String applicationName;
    private String message;
    private CommonExceptionEnums exceptionEnums;
    private String exceptionDesc;

    public BusinessException(String applicationName,String message,Throwable throwable){
        super(message,throwable);
        this.applicationName = applicationName;
        this.message = message;
        this.exceptionEnums = CommonExceptionEnums.ERROR_COMMON;
        this.exceptionDesc = String.format("服务[%s]异常：{错误编码:%s,错误信息:%s}",this.applicationName,this.exceptionEnums.code(),this.message);
    }

    public BusinessException(String applicationName,CommonExceptionEnums enums,String message){
        super(message);
        this.applicationName = applicationName;
        this.message = message;
        this.exceptionEnums = enums;
        this.exceptionDesc = String.format("服务[%s]异常：{错误编码:%s,错误信息:%s}",this.applicationName,this.exceptionEnums.code(),this.message);
    }

}
